This repository has been archived on 2025-01-01. You can view files and clone it, but cannot push or open issues or pull requests.
ShiftOS_TheReturn/ShiftOS.Objects/Save.cs

130 lines
3.8 KiB
C#
Raw Normal View History

2017-02-26 14:51:11 -05:00
/*
2017-02-24 20:24:57 -05:00
* MIT License
*
* Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
using System;
using System.Collections.Generic;
2017-02-02 09:47:23 -05:00
using System.Dynamic;
using System.Linq;
using System.Threading;
namespace ShiftOS.Objects
{
//Better to store this stuff server-side so we can do some neat stuff with hacking...
public class Save
{
2017-06-28 16:33:07 -04:00
public List<ViralInfection> ViralInfections { get; set; }
2017-06-02 11:38:38 -04:00
public bool MusicEnabled = true;
public bool SoundEnabled = true;
public int MusicVolume = 100;
public string Username = "user";
2017-06-10 10:17:10 -04:00
public bool IsSandbox = false;
2017-06-10 22:02:10 -04:00
public ulong Codepoints { get; set; }
public Dictionary<string, bool> Upgrades { get; set; }
public int StoryPosition { get; set; }
public string Language { get; set; }
public string SystemName { get; set; }
2017-02-26 14:51:11 -05:00
public int ShiftnetSubscription { get; set; }
2017-02-12 18:35:15 -05:00
public Guid ID { get; set; }
2017-03-06 20:05:24 -05:00
public List<string> StoriesExperienced { get; set; }
public int CountUpgrades()
{
int count = 0;
foreach (var upg in Upgrades)
{
if (upg.Value == true)
count++;
}
return count;
}
2017-06-04 15:18:53 -04:00
/// <summary>
/// DO NOT MODIFY THIS. EVER. YOU WILL BREAK THE STORYLINE. Let the engine do it's job.
/// </summary>
public string PickupPoint { get; set; }
}
2017-02-02 09:47:23 -05:00
public class SettingsObject : DynamicObject
{
private Dictionary<string, object> _settings = null;
public SettingsObject()
{
_settings = new Dictionary<string, object>();
}
public override IEnumerable<string> GetDynamicMemberNames()
{
return _settings.Keys.ToArray();
}
public override bool TryGetMember(GetMemberBinder binder, out object result)
{
if (_settings.ContainsKey(binder.Name))
{
result = _settings[binder.Name];
return true;
}
else
{
result = null;
return false;
}
}
public override bool TrySetMember(SetMemberBinder binder, object value)
{
2017-02-08 18:01:13 -05:00
try
2017-02-02 09:47:23 -05:00
{
2017-02-08 18:01:13 -05:00
if (_settings.ContainsKey(binder.Name))
{
_settings[binder.Name] = value;
}
else
{
_settings.Add(binder.Name, value);
}
2017-02-02 09:47:23 -05:00
}
2017-02-08 18:01:13 -05:00
catch
2017-02-02 09:47:23 -05:00
{
2017-02-08 18:01:13 -05:00
2017-02-02 09:47:23 -05:00
}
return true;
}
}
2017-06-28 16:33:07 -04:00
public class ViralInfection
{
public string ID { get; set; }
public int ThreatLevel { get; set; }
}
}