Esempio n. 1
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);
                    }
                }
            }));
        }
Esempio n. 2
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);
                        }
                    }
                }
            }));
        }
Esempio n. 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);
                        }
                    }
                }
            }));
        }
Esempio n. 4
0
 // Filter hit by hit IDs list
 private static bool isHitConformingHitId(HitInformation hit, AnyOrAllOptions hitIdsOptions, int[] hitIds)
 {
     if (hitIdsOptions == AnyOrAllOptions.anyOf)
     {
         return(hitIds != null && hitIds.Contains(hit.hitData.hitboxID));
     }
     else
     {
         return(hitIds == null || !hitIds.Contains(hit.hitData.hitboxID));
     }
 }
Esempio n. 5
0
 // Filter hit by collision IDs list
 private static bool isHitConformingCollisionId(HitInformation hit, AnyOrAllOptions collisionIdsOptions, int[] collisionIds)
 {
     if (collisionIdsOptions == AnyOrAllOptions.anyOf)
     {
         return(collisionIds != null && collisionIds.Contains(hit.collisionId));
     }
     else
     {
         return(collisionIds == null || !collisionIds.Contains(hit.collisionId));
     }
 }
Esempio n. 6
0
 // Filter hit by types list
 private static bool isHitConformingType(HitInformation hit, AnyOrAllOptions typesOptions, int[] types)
 {
     if (typesOptions == AnyOrAllOptions.anyOf)
     {
         return(types != null && types.Contains((int)hit.hitData.type));
     }
     else
     {
         return(types == null || !types.Contains((int)hit.hitData.type));
     }
 }
        private static EventCondition <GameEntityModel> .EvaluationDelegate BuildAnimation(Storage.GenericParameter parameter, out int keyFrame, Storage.CharacterAnimation animation)
        {
            keyFrame = InvalidKeyframe;
            // Read anchor options, anchor IDs and if it's a single subject
            AnyOrAllOptions options = (AnyOrAllOptions)parameter.SafeInt(1);

            string[] names = parameter.SafeStringsList(0);

            return(delegate(GameEntityModel mainModel, List <GameEntityModel>[] subjectModels){
                AnimationModel animModel = StateManager.state.GetModel(mainModel.animationModelId) as AnimationModel;
                bool anyOf = options == AnyOrAllOptions.anyOf;
                // "smart" loop here
                foreach (string name in names)
                {
                    if (animModel.animationName == name)
                    {
                        return anyOf;
                    }
                }
                return !anyOf;
            });
        }