Beispiel #1
0
        // 5: GetHitters
        private static EventSubject <GameEntityModel> .GetSubjectsDelegate GetHitters(Storage.GenericParameter parameter)
        {
            // Read orientation options, types options, list of types, collision ids options, collision ids list
            OrientationOptions orientationOptions = (OrientationOptions)parameter.SafeInt(1);
            AnyOrAllOptions    typesOptions       = (AnyOrAllOptions)parameter.SafeInt(2);

            int[]           types = parameter.SafeIntsList(0);
            AnyOrAllOptions collisionIdsOptions = (AnyOrAllOptions)parameter.SafeInt(3);

            int[] collisionIds = parameter.SafeIntsList(1);
            int   subjectId    = parameter.SafeInt(0);

            return(DefaultDelegation(subjectId, delegate(GameEntityModel model, List <GameEntityModel> subjects){
                GameEntityController controller = model.Controller() as GameEntityController;
                List <HitInformation> hurts = controller.lastHurts;
                GameEntityModel subject;
                foreach (HitInformation hitInformation in hurts)
                {
                    if (isHitConformingType(hitInformation, typesOptions, types) &&
                        isHitConformingCollisionId(hitInformation, collisionIdsOptions, collisionIds)
                        )
                    {
                        subject = getHitEntityIfConformingOrientationOptions(hitInformation, orientationOptions, model);
                        if (subject != null)
                        {
                            subjects.Add(subject);
                        }
                    }
                }
            }));
        }
Beispiel #2
0
        // 6: GetHittens
        private static EventSubject <GameEntityModel> .GetSubjectsDelegate GetHittens(Storage.GenericParameter parameter)
        {
            // Read types options, list of types, hit ids options, hit ids list
            AnyOrAllOptions typesOptions = (AnyOrAllOptions)parameter.SafeInt(1);

            int[]           types         = parameter.SafeIntsList(0);
            AnyOrAllOptions hitIdsOptions = (AnyOrAllOptions)parameter.SafeInt(2);

            int[] hitIds    = parameter.SafeIntsList(1);
            int   subjectId = parameter.SafeInt(0);

            return(DefaultDelegation(subjectId, delegate(GameEntityModel model, List <GameEntityModel> subjects){
                GameEntityController controller = model.Controller() as GameEntityController;
                List <HitInformation> hits = controller.lastHits;
                GameEntityModel subject;
                foreach (HitInformation hitInformation in hits)
                {
                    if (isHitConformingType(hitInformation, typesOptions, types) &&
                        isHitConformingHitId(hitInformation, hitIdsOptions, hitIds)
                        )
                    {
                        subject = StateManager.state.GetModel(hitInformation.entityId) as GameEntityModel;
                        subjects.Add(subject);
                    }
                }
            }));
        }
Beispiel #3
0
        // 4: GetGrabbed
        private static EventSubject <GameEntityModel> .GetSubjectsDelegate GetGrabbed(Storage.GenericParameter parameter)
        {
            // Read anchor options, anchor IDs and if it's a single subject
            AnyOrAllOptions anchorOptions = (AnyOrAllOptions)parameter.SafeInt(1);

            int[] anchorIds = parameter.SafeIntsList(0);
            int   subjectId = parameter.SafeInt(0);

            return(DefaultDelegation(subjectId, delegate(GameEntityModel model, List <GameEntityModel> subjects){
                List <ModelReference> anchoredEntities = model.anchoredEntities;
                if (anchorOptions == AnyOrAllOptions.anyOf)
                {
                    // Add all from given anchors
                    foreach (int anchorId in anchorIds)
                    {
                        if (anchorId >= 0 && anchorId < anchoredEntities.Count)
                        {
                            subjects.Add(StateManager.state.GetModel(anchoredEntities[anchorId]) as GameEntityModel);
                        }
                    }
                }
                else
                {
                    // Add all but the given anchors
                    for (int anchorId = 0; anchorId < anchoredEntities.Count; ++anchorId)
                    {
                        if (!anchorIds.Contains(anchorId))
                        {
                            subjects.Add(StateManager.state.GetModel(anchoredEntities[anchorId]) as GameEntityModel);
                        }
                    }
                }
            }));
        }
Beispiel #4
0
        private static EventAction <GameEntityModel> .ExecutionDelegate BuildSpawnEntity(Storage.GenericParameter parameter)
        {
            string entityName        = parameter.SafeString(0);
            int    locationType      = parameter.SafeInt(1);
            int    localtionAnchorId = parameter.SafeInt(2);
            string initialAnimation  = parameter.SafeString(1);
            int    teamId            = parameter.SafeInt(3);
            bool   own = parameter.SafeBool(0);

            string[]     variableNames  = parameter.SafeStringsList(0);
            int[]        variableValues = parameter.SafeIntsList(0);      // what if using referenced values from something else?, [energy] etc
            int          facingOptions  = parameter.SafeInt(4);
            FixedVector3 offset         = BuildFixedVector3(parameter, 0);

            return(delegate(GameEntityModel model, List <GameEntityModel>[] subjectModels){
                // TODO
            });
        }