Ejemplo n.º 1
0
        public Dictionary <string, object> GetPos(CpuBlock cpu)
        {
            Vector3 myPos = Rigidbody.position;

            return(new Dictionary <string, object> {
                { "absolutePos", BlockUtils.Vec2Obj(cpu, myPos) }
            });
        }
Ejemplo n.º 2
0
        public Dictionary <string, object> GetV(CpuBlock cpu)
        {
            Vector3 myV = Rigidbody.velocity;

            return(new Dictionary <string, object> {
                { "velocity", BlockUtils.Vec2Obj(cpu, myV) }
            });
        }
Ejemplo n.º 3
0
        public Dictionary <string, object> GetAng(CpuBlock cpu)
        {
            Quaternion quaternion = base.transform.rotation;
            Vector3    angV       = Rigidbody.angularVelocity;

            return(new Dictionary <string, object>
            {
                { "quaternion", BlockUtils.Quat2Obj(cpu, quaternion) },
                { "velocity", BlockUtils.Vec2Obj(cpu, angV) }
            });
        }
Ejemplo n.º 4
0
        public Dictionary <string, object> GetTargetObject(CpuBlock cpu)
        {
            if (closestCollider == null)
            {
                return(null);
            }

            if (detectedObjectInfo != null)
            {
                return(detectedObjectInfo);
            }

            // Static objects have rigidBody.isKinematic
            var rigidBody = closestCollider.attachedRigidbody;
            // Mesh has no rigidbody
            var isStaic   = (rigidBody == null || rigidBody.isKinematic);
            var transform = closestCollider.transform;
            // AI has EntityAI
            var parentAI = transform.GetComponentInParent <EntityAI>();
            var simpleAI = transform.GetComponentInParent <EnemyAISimple>();
            // Blocks have BlockBehavior
            var parentBlock = transform.GetComponentInParent <BlockBehaviour>();
            var objectInfo  = rigidBody?.GetComponentInParent <SimBehaviour>();
            var bombInfo    = rigidBody?.GetComponentInParent <ExplodeOnCollide>();
            var killable    = rigidBody?.GetComponentInParent <InjuryController>();
            var projectile  = rigidBody?.GetComponentInParent <ProjectileScript>();
            var isDead      = parentAI != null && parentAI.isDead || simpleAI != null && simpleAI.isDead;
            var canBreak    = objectInfo is IExplosionEffect ||
                              rigidBody?.GetComponent <PhysNodeTile>() != null ||
                              rigidBody?.GetComponent <StructuralPhysTile>() != null;
            var objectType = (bombInfo != null || (parentBlock is ExplodeOnCollideBlock) ? "bomb"
                                : parentBlock != null ? "block"
                                : projectile != null ? "projectile"
                                : isDead ? "dead"
                                : parentAI != null || simpleAI != null ? "unit"
                                : killable != null ? "creature"
                                : canBreak ? "breakable"
                                : objectInfo != null ? "entity"
                                : "other");
            Vector3 relativePos = closestPoint - sensorPos.position;
            Vector3 targetV     = rigidBody ? rigidBody.velocity : Vector3.zero;

            detectedObjectInfo = new Dictionary <string, object>
            {
                { "static", isStaic ? (long)1 : 0 },
                { "type", objectType },
                { "relativePos", BlockUtils.Vec2Obj(cpu, relativePos) },
                { "absolutePos", BlockUtils.Vec2Obj(cpu, closestPoint) },
                { "velocity", BlockUtils.Vec2Obj(cpu, targetV) }
            };

            return(detectedObjectInfo);
        }