summaryrefslogtreecommitdiffstats
path: root/System.c4g/Utility.c
diff options
context:
space:
mode:
authorMarkus Mittendrein <git@maxmitti.tk>2017-01-02 19:34:09 +0100
committerMarkus Mittendrein <git@maxmitti.tk>2017-01-02 19:34:09 +0100
commit1f280cb06cc579c2a98d215e202dc0642fb40a3d (patch)
tree30a19973594d30792947aa624e7bf585eaa0cf40 /System.c4g/Utility.c
downloadDTTubeMail.c4d-1f280cb06cc579c2a98d215e202dc0642fb40a3d.tar.gz
DTTubeMail.c4d-1f280cb06cc579c2a98d215e202dc0642fb40a3d.zip
Initial
Diffstat (limited to 'System.c4g/Utility.c')
-rw-r--r--System.c4g/Utility.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/System.c4g/Utility.c b/System.c4g/Utility.c
new file mode 100644
index 0000000..1d58f8d
--- /dev/null
+++ b/System.c4g/Utility.c
@@ -0,0 +1,62 @@
+#strict 2
+
+global func GetLineEnd(object otherEnd, bool second, object line)
+{
+ line = line || this;
+ var ret = GetActionTarget(!!second, line);
+ if(otherEnd && otherEnd == ret)
+ {
+ ret = GetActionTarget(!second, line);
+ }
+ return ret;
+}
+
+global func Find_Tube(object target)
+{
+ return Find_Line(TK7I_Tube, target);
+}
+
+global func Find_Line(id type, object target)
+{
+ target = target || this;
+ return [C4FO_Func, "Find_LineCheck", type, target];
+}
+
+global func Find_LineCheck(id type, object target)
+{
+ return (!type || type == GetID(this)) && GetProcedure() == "CONNECT" && (GetActionTarget(0) == target || GetActionTarget(1) == target);
+}
+
+global func Put(object container, object obj)
+{
+ obj = obj || this;
+ if(container->GetOCF() & OCF_Collection)
+ {
+ return container->Collect(obj);
+ }
+ else
+ {
+ return CanCollect(container, obj, GetID(obj)) && obj->Enter(container) && (container->~Collection(obj, !(GetOCF(container) & OCF_Entrance)) || true);
+ }
+}
+
+global func CanCollect(object container, object obj, id id)
+{
+ id = id || GetID(obj);
+ var collectionLimit = GetDefCoreVal("CollectionLimit", "DefCore", GetID(container), 0);
+ if(!collectionLimit || container->ContentsCount() < collectionLimit)
+ {
+ return !container->~RejectCollect(id, obj) && (!obj || !obj->~RejectEntrance(container));
+ }
+ return false;
+}
+
+global func Find_GrabPutGet(int type)
+{
+ return [C4FO_Func, "Find_GrabPutGetCheck", type];
+}
+
+global func Find_GrabPutGetCheck(int type)
+{
+ return GetDefGrabPutGet(GetID()) & type;
+}