Пример #1
0
        public SynapseObject SpawnSchematic(SynapseSchematic schematic, Vector3 position)
        {
            if (schematic == null)
            {
                return(null);
            }

            var so = new SynapseObject(schematic);

            so.Position = position;
            return(so);
        }
Пример #2
0
        public void AddSchematic(SynapseSchematic schematic, bool removeOnReload = true)
        {
            if (IsIDRegistered(schematic.ID))
            {
                return;
            }
            schematic.reload = removeOnReload;
            var list = Schematics.ToList();

            list.Add(schematic);
            Schematics = list.AsReadOnly();
        }
Пример #3
0
        public void SaveSchematic(SynapseSchematic schematic, string fileName)
        {
            if (IsIDRegistered(schematic.ID))
            {
                return;
            }
            AddSchematic(schematic);

            var syml    = new SYML(Path.Combine(Server.Get.Files.SchematicDirectory, fileName + ".syml"));
            var section = new ConfigSection {
                Section = schematic.Name
            };

            section.Import(schematic);
            syml.Sections.Add(schematic.Name, section);
            syml.Store();
        }
Пример #4
0
        public SynapseObject(SynapseSchematic schematic)
        {
            Name             = schematic.Name;
            ID               = schematic.ID;
            CustomAttributes = schematic.CustomAttributes;
            GameObject       = new GameObject(Name);

            foreach (var primitive in schematic.PrimitiveObjects)
            {
                var obj = new SynapsePrimitiveObject(primitive);
                PrimitivesChildrens.Add(obj);
                Childrens.Add(obj);
                obj.GameObject.transform.parent = GameObject.transform;
                obj.Parent = this;
            }

            foreach (var light in schematic.LightObjects)
            {
                var obj = new SynapseLightObject(light);
                LightChildrens.Add(obj);
                Childrens.Add(obj);
                obj.GameObject.transform.parent = GameObject.transform;
                obj.Parent = this;
            }

            foreach (var target in schematic.TargetObjects)
            {
                var obj = new SynapseTargetObject(target);
                TargetChildrens.Add(obj);
                Childrens.Add(obj);
                obj.GameObject.transform.parent = GameObject.transform;
                obj.Parent = this;
            }

            foreach (var item in schematic.ItemObjects)
            {
                var obj = new SynapseItemObject(item);
                ItemChildrens.Add(obj);
                Childrens.Add(obj);
                obj.GameObject.transform.parent = GameObject.transform;
                obj.Parent = this;
            }

            foreach (var station in schematic.WorkStationObjects)
            {
                var obj = new SynapseWorkStationObject(station);
                WorkStationChildrens.Add(obj);
                Childrens.Add(obj);
                obj.GameObject.transform.parent = GameObject.transform;
                obj.Parent = this;
            }

            foreach (var door in schematic.DoorObjects)
            {
                var obj = new SynapseDoorObject(door);
                DoorChildrens.Add(obj);
                Childrens.Add(obj);
                obj.GameObject.transform.parent = GameObject.transform;
                obj.Parent = this;
            }

            Map.Get.SynapseObjects.Add(this);

            var script = GameObject.AddComponent <SynapseObjectScript>();

            script.Object = this;
        }
Пример #5
0
 public SynapseObject SpawnSchematic(SynapseSchematic schematic, Vector3 position, Vector3 rotation) => SpawnSchematic(schematic, position, Quaternion.Euler(rotation));