コード例 #1
0
        public TargetDirections DirectionType;      // direction for cone and dest targets

        public StaticTargetData(TargetObjects objectType, TargetReferences referenceType,
                                TargetSelections selectionCategory, TargetChecks selectionCheckType, TargetDirections directionType)
        {
            ObjectType         = objectType;
            ReferenceType      = referenceType;
            SelectionCategory  = selectionCategory;
            SelectionCheckType = selectionCheckType;
            DirectionType      = directionType;
        }
コード例 #2
0
 /// <summary>
 /// Fills up the list of available Targets to be used when needed to be spawned.
 /// Sends a copy of the reference correspondent to each target to itself so that it can be used when destruction is needed.
 /// </summary>
 private void InstantiateObjectPool()
 {
     for (int i = 0; i < _maxNumberOfTargets; ++i)
     {
         GameObject       temp          = GameObject.Instantiate(_targetPrefab, _targetsParent);
         TargetReferences tempTargetRef = default;
         tempTargetRef.mainObj          = temp;
         tempTargetRef.targetController = temp.GetComponent <TargetController>();
         tempTargetRef.targetController.SetTargetReference(tempTargetRef);
         _availableTargets.Add(tempTargetRef);
     }
 }
コード例 #3
0
ファイル: WeaveTask.cs プロジェクト: 71/insider
        public override bool Execute()
        {
            try
            {
                using (Outsider outsider = new Outsider(TargetAssembly, TargetPath, TargetReferences.Split(';')))
                {
                    outsider.Weaver.MessageLogged += MessageLogged;
                    outsider.Weaver.Process();
                }
            }
            catch (Exception e)
            {
                EncounteredError = true;
            }

            return(!EncounteredError);
        }
コード例 #4
0
        internal static void HandleObjectChange <T>(IUnifiedIMObject obj)
        {
            string key = obj.ObjectID;
            Type   t   = typeof(T);


            if (UnifiedSystem.AllowReferences || UnifiedSystem.AllowIndexes)
            {
                //Loop over Changes
                foreach (KeyValuePair <string, UIMPropertyState> changeState in obj.PropertyStates)
                {
                    object cVal = Property.Get(obj, changeState.Key) ?? null;
                    changeState.Value.HasChangedAndUpdate(cVal, (oldVal, newVal) =>
                    {
                        //Index Updating
                        if (AllowIndexes)
                        {
                            FixIndex(obj, t, changeState.Key, changeState.Value.LastState);
                        }

                        //Reference Updating
                        if (AllowReferences)
                        {
                            if (HostReferences.ContainsKey(t))
                            {
                                UnifiedIMReference hRefs = HostReferences[t].FirstOrDefault(x => x.HostProperty == changeState.Key);
                                if (hRefs != null)
                                {
                                    DeleteReference(obj, hRefs);
                                    ResolveReference(obj, hRefs, t);
                                }
                            }
                            if (TargetReferences.ContainsKey(t))
                            {
                                List <UnifiedIMReference> tRefs = TargetReferences[t].Where(x => x.TargetProperty == changeState.Key).ToList();
                                foreach (UnifiedIMReference reff in tRefs)
                                {
                                    DeleteReference(obj, reff);
                                    ResolveReference(obj, reff);
                                }
                            }
                        }
                    });
                }
            }
        }
コード例 #5
0
    /// <summary>
    /// Spawns a target.
    /// Resets the target health value.
    /// Calls the TargetSpawned method that tells the target that it has been spawned so that it can do whatever is needed.
    /// </summary>
    private void SpawnTarget(int targetHealth = 1)
    {
        _pointSearchCounter = 0;
        int     randomSpawnArea = UnityEngine.Random.Range(0, _targetSpawnAreas.Length);
        Vector3 tempSpawnPos    = GetRandomPointInCollider(_targetSpawnAreas[randomSpawnArea].areaCollider);

        if (_availableTargets.Count > 0)
        {
            TargetReferences tempTargetRef = _availableTargets[_availableTargets.Count - 1];
            tempTargetRef.mainObj.transform.position = tempSpawnPos;
            tempTargetRef.targetController.ResetTarget(targetHealth);
            tempTargetRef.targetController.TargetSpawned();
            tempTargetRef.mainObj.SetActive(true);
            tempTargetRef.targetController.OrientateAndLaunchTarget(_targetSpawnAreas[randomSpawnArea].launchDirection, _targetSpawnAreas[randomSpawnArea].forwardOrientation);
            _onUseTargets.Add(tempTargetRef);
            _availableTargets.RemoveAt(_availableTargets.Count - 1);
        }
    }
コード例 #6
0
        internal static void RegisterType(Type type)
        {
            if (AllowReferences)
            {
                PropertyInfo[] props = type.GetPropertiesCached()
                                       .Union(type.GetProperties(BindingFlags.NonPublic | BindingFlags.Instance))
                                       .ToArray();
                foreach (PropertyInfo prop in props)
                {
                    UnifiedIMReference reff = prop.GetCustomAttribute <UnifiedIMReference>();
                    UnifiedIMIndex     indx = prop.GetCustomAttribute <UnifiedIMIndex>();
                    bool alreadyIndexed     = false;

                    if (reff != null)
                    {
                        if (reff.HostPropertyType == null)
                        {
                            reff.HostPropertyType = props.FirstOrDefault(x => x.Name == reff.HostProperty)?.PropertyType;
                        }
                        if (reff.HostType == null)
                        {
                            reff.HostType = prop.DeclaringType;
                        }
                        reff.SetProperty     = prop.Name;
                        reff.SetPropertyType = prop.PropertyType;
                        if (reff.SetPropertyType == null)
                        {
                            throw new ArgumentException("Set Property does not exist");
                        }
                        References.Add(reff);
                        if (!HostReferences.ContainsKey(type))
                        {
                            HostReferences.Add(type, new List <UnifiedIMReference>());
                        }
                        HostReferences[type].Add(reff);
                        if (!TargetReferences.ContainsKey(reff.TargetType))
                        {
                            TargetReferences.Add(reff.TargetType, new List <UnifiedIMReference>());
                        }
                        TargetReferences[reff.TargetType].Add(reff);
                        if (!TypeReferences.ContainsKey(reff.HostType))
                        {
                            TypeReferences.Add(reff.HostType, new List <UnifiedIMReference>());
                        }
                        if (!TypeReferences.ContainsKey(reff.TargetType))
                        {
                            TypeReferences.Add(reff.TargetType, new List <UnifiedIMReference>());
                        }
                        TypeReferences[reff.TargetType].Add(reff);
                        TypeReferences[reff.HostType].Add(reff);
                        if (AllowIndexes && CreateReferenceIndexes)
                        {
                            if (reff.TargetProperty != "ObjectID" && !HasIndex(reff.TargetType, reff.TargetProperty))
                            {
                                AddIndex(reff.TargetType, reff.TargetProperty);
                            }
                            if (reff.HostProperty != "ObjectID" && !HasIndex(reff.HostType, reff.HostProperty))
                            {
                                AddIndex(reff.HostType, reff.HostProperty);
                            }

                            if (reff.TargetType == type || reff.HostType == type)
                            {
                                alreadyIndexed = true;
                            }
                        }
                    }

                    if (!alreadyIndexed && prop.Name != "ObjectID" && indx != null)
                    {
                        AddIndex(type, prop.Name);
                    }
                }
            }

            if (!_databaseGetters.ContainsKey(type))
            {
                _databaseGetters.Add(type, ((IUnifiedIMObject)Activator.CreateInstance(type)).DatabaseBase);
            }
        }
コード例 #7
0
 /// <summary>
 /// Method called by the Targets themselves once they are hit enough times to be destroyed.
 /// Disables the GO of the target and adds it to the available targets list.
 /// </summary>
 /// <param name="target"></param>
 public void TargetDestroyed(TargetReferences target)
 {
     target.mainObj.SetActive(false);
     _onUseTargets.Remove(target);
     _availableTargets.Add(target);
 }